package services;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import model.User;
import dao.IUserDAO;
import dao.UserDAO;

@Service("userServices")
public class UserServices implements IUserDAO {

	@Autowired
	UserDAO userDao;
	
	@Autowired
	ManufacturerServices manufacturerServices;

	@Override
	public void addUser(String username, String password, String address,
			String birthday, String sex, String email, int role) {
		userDao.addUser(username, password, address, birthday, sex, email, role);
	}

	@Override
	public User getOneUser(int id) {
		return userDao.getOneUser(id);
	}

	@Override
	public List<User> getUserByRole(String role) {
		return userDao.getUserByRole(role);
	}

	@Override
	public User getOneUser(String username) {
		return userDao.getOneUser(username);
	}

	@Override
	public void deleteUser(int id) {
		manufacturerServices.deleteManufacturerByUID(id);
		userDao.deleteUser(id);
	}

	@Override
	public void updateUser(String username, String password, int role,
			String birthday, String address, String sex, String email, int id) {
		userDao.updateUser(username, password, role, birthday, address, sex,
				email, id);

	}

	@Override
	public List<User> getAllUsers() {
		return userDao.getAllUsers();
	}

}
